//
//  BBMyJobViewController.m
//  BearSiX
//
//  Created by BearBaby on 16/3/28.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBMyJobViewController.h"
#import "BBSixHeader.h"
#import "BBMyJobCell.h"
#import "BBTaskDetailViewController.h"
#import "BBMyReleaseJobViewController.h"
@interface BBMyJobViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView* tableView;
@property(nonatomic,strong)BBMyReleaseJobViewController* releaseVC;
@property(nonatomic,strong)BBTaskDetailViewController* taskVC;
@end

@implementation BBMyJobViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"任务";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEHEIGHT) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 1;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        UITableViewCell* cell1 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell1.textLabel.text = @"我发布的任务";
        cell1.textLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
        cell1.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell1;
    }
    static NSString* identifire = @"Cell";
    BBMyJobCell* cell = [self.tableView dequeueReusableCellWithIdentifier:identifire];
    if (!cell) {
        cell = [[BBMyJobCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifire];
      
        cell.delegate = self;
        
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        return 44;
    }else{
    CGFloat cellHeight = 0.0f;
    BBMyJobCell* cell = (BBMyJobCell*)[self tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath];
    cellHeight = cell.finalH;

    return cellHeight;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  
    return 0.000001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==1) {
        return 30;
    }else{
        return 15;
    }
    return 30;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    NSString* string = nil;
    if (section==1) {
        string = @"我收到的任务(3)";
    }else{
        
        string = @"";
    }
    
    
    return string;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section==0) {
       
        self.releaseVC = [[BBMyReleaseJobViewController alloc]init];
        [self.navigationController pushViewController:self.releaseVC animated:YES];
    }else{
        self.taskVC = [[BBTaskDetailViewController alloc]init];
        [self.navigationController pushViewController:self.taskVC animated:YES];
    
    }


}
@end
